package com.itheima.reggie.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.reggie.common.ResultInfo;
import com.itheima.reggie.domain.Order;
import com.itheima.reggie.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

// 订单模块
@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private OrderService orderService;

    // 提交订单
    @PostMapping("/submit")
    public ResultInfo submit(@RequestBody Order order){ //接收参数
        // 调用方法
        orderService.submit(order);
        // 返回结果
        return ResultInfo.success();
    }

    // 历史订单
    @GetMapping("/userPage")
    public ResultInfo lishidingdan(@RequestParam(name = "page") Integer pageNum,
                                   @RequestParam(name = "pageSize") Integer pageSize){ //接收参数
        // 调用方法
     Page<Order> orderPage= orderService.lishidingdan(pageNum,pageSize);
     // 返回结果
        return ResultInfo.success(orderPage);

    }



}
